package yifeng.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class HelloHandler implements InvocationHandler {
	
	private Object originObj;
	
	public HelloHandler(Object originObj) {
		super();
		this.originObj = originObj;
	}


	@Override
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		doBefore();
		
		Object result;
		
		result = method.invoke(originObj, args);
		
		doAfter();
		return result;
	}

	
	
	
	
	private void doAfter() {
		System.out.println("After");
	}

	private void doBefore() {
		System.out.println("Before");
	}

}
